package com.example.service;

import com.example.db.DataSourceUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class UserService {


    public static void getUser(){
        Connection conn = DataSourceUtil.getConnection();
        String sql = "SELECT * FROM user";
        try {
            Statement st = conn.createStatement();
            ResultSet rs = st.executeQuery(sql);
            while (rs.next()){
                System.out.println(rs.getString("name"));
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }finally {
            DataSourceUtil.releaseConnection(conn);
        }
    }

    public static void main(String[] args) {
        getUser();
    }
}
